{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "d514b0e6",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "import seaborn as sns\n",
    "import os\n",
    "\n",
    "from IPython.display import clear_output\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "349f3171",
   "metadata": {},
   "source": [
    "## Load RAG output files"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "109057cd",
   "metadata": {},
   "outputs": [],
   "source": [
    "neo4j_rag = pd.read_csv('../data/results/cypher_rag_output.csv')\n",
    "kg_rag = pd.read_csv('../data/results/kg_rag_output.csv')\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "38565176",
   "metadata": {},
   "source": [
    "## Token usage comparison"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "12e415b1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAWsAAAESCAYAAAA7a/RxAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/H5lhTAAAACXBIWXMAAA9hAAAPYQGoP6dpAAA4X0lEQVR4nO3deVxU1fsH8M/IMizDIiirxCIE4o4bqEkmikuiaWV8MXdTQkXURH+llhuKL1PLNEvETDNNbdFy4YviFkouuIO7uICkyAAiIMzz+4MvV6+gcmEQLjzv1+u+ZM45985zmeGZ65lzz1EQEYExxliNVq+6A2CMMfZynKwZY0wGOFkzxpgMcLJmjDEZ4GTNGGMywMmaMcZkgJM1Y4zJACfrciAiZGVlgYekM8aqCyfrcsjOzoaZmRmys7OrOxTGWB3FyZoxxmSAkzVjjMkAJ2vGGJMBTtaMMSYDnKwZY0wGOFkzxpgMcLJmjDEZqNZkXVRUhBkzZsDZ2RmGhoZo3Lgx5syZI7r5hIgwc+ZM2NrawtDQEH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PDwoODiYLC0tKTIyssx9Fy5cSFZWVlRQUEBEVKk4WOXxFKk1VE5ODuzt7REdHY0BAwaI6t588020atWKbydnrA7hLxhrGI1Gg3v37mHx4sUwNzdHQEBAdYfEGKsBOFnXMCkpKXB2dkajRo2wdu1a0Tf0jLG6i7tBGGNMBng0CGOMyQAna8YYkwFO1owxJgOcrBljTAY4WTPGmAxwsmaMMRngZM0YYzLAyZoxxmTg/wE8al8OX3/hnwAAAABJRU5ErkJggg==",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "There is 53.9% reduction in token usage for KG-RAG compared to Cypher-RAG\n"
     ]
    }
   ],
   "source": [
    "neo4j_rag.loc[:, 'token_usage'] = 0.5*(neo4j_rag.total_tokens_used + neo4j_rag.total_tokens_used_perturbed)\n",
    "kg_rag.loc[:, 'token_usage'] = 0.5*(kg_rag.total_tokens_used + kg_rag.total_tokens_used_perturbed)\n",
    "\n",
    "neo4j_avg = neo4j_rag['token_usage'].mean()\n",
    "neo4j_sem = neo4j_rag['token_usage'].sem()\n",
    "\n",
    "kg_avg = kg_rag['token_usage'].mean()\n",
    "kg_sem = kg_rag['token_usage'].sem()\n",
    "\n",
    "\n",
    "fig = plt.figure(figsize=(3, 3))\n",
    "\n",
    "plt.bar(0, neo4j_avg, yerr=neo4j_sem, color='red', ecolor='black', capsize=5, label='Cypher-RAG')\n",
    "\n",
    "plt.bar(1, kg_avg, yerr=kg_sem, color='green', ecolor='black', capsize=5, label='KG-RAG')\n",
    "\n",
    "plt.ylabel('Average token usage')\n",
    "plt.xticks([0, 1], ['Cypher-RAG', 'KG-RAG'])\n",
    "\n",
    "sns.despine()\n",
    "\n",
    "plt.legend(loc='center left', bbox_to_anchor=(0.6, 0.75))\n",
    "\n",
    "plt.show()\n",
    "\n",
    "percentage_of_reduction_in_token_usage = round(100*(neo4j_avg-kg_avg)/neo4j_avg,1)\n",
    "print(f'There is {percentage_of_reduction_in_token_usage}% reduction in token usage for KG-RAG compared to Cypher-RAG')\n",
    "\n",
    "fig_path = '../data/results/figures'\n",
    "os.makedirs(fig_path, exist_ok=True)\n",
    "fig.savefig(os.path.join(fig_path, 'token_usage_comparison.svg'), format='svg', bbox_inches='tight')      \n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8ea726fd",
   "metadata": {},
   "source": [
    "## Retrieval accuracy comparison"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5004ceb3",
   "metadata": {},
   "source": [
    "### Cypher-RAG"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "757f36d5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Correct retrieval percentage for Cypher-RAG 75.0%\n",
      "Correct retrieval percentage for KG-RAG 97.0%\n"
     ]
    }
   ],
   "source": [
    "\n",
    "neo4j_rag_no_nan = neo4j_rag.dropna(subset=['neo4j_rag_answer'])\n",
    "neo4j_rag_no_nan.loc[:, 'contains_pvalue'] = neo4j_rag_no_nan.apply(lambda row: str(row['gwas_pvalue']) in str(row['neo4j_rag_answer']), axis=1)\n",
    "neo4j_rag_yes_count_df = neo4j_rag_no_nan[neo4j_rag_no_nan.neo4j_rag_answer.str.contains('Yes')]\n",
    "neo4j_rag_yes_count = neo4j_rag_yes_count_df.shape[0]\n",
    "indices_to_remove = neo4j_rag_yes_count_df.index.tolist()\n",
    "neo4j_rag_no_nan = neo4j_rag_no_nan.drop(indices_to_remove)\n",
    "neo4j_rag_p_value_correct_retrieval_count = neo4j_rag_no_nan[neo4j_rag_no_nan.contains_pvalue==True].shape[0]\n",
    "neo4j_rag_total_correct_retrieval = neo4j_rag_yes_count + neo4j_rag_p_value_correct_retrieval_count\n",
    "\n",
    "kg_rag_no_nan = kg_rag.dropna(subset=['kg_rag_answer'])\n",
    "kg_rag_yes_count_df = kg_rag_no_nan[kg_rag_no_nan.kg_rag_answer.str.contains('Yes')]\n",
    "kg_rag_yes_count = kg_rag_yes_count_df.shape[0]\n",
    "indices_to_remove = kg_rag_yes_count_df.index.tolist()\n",
    "kg_rag_no_nan = kg_rag_no_nan.drop(indices_to_remove)\n",
    "kg_rag_no_nan.loc[:, 'contains_pvalue'] = kg_rag_no_nan.apply(lambda row: str(row['gwas_pvalue']) in str(row['kg_rag_answer']), axis=1)\n",
    "kg_rag_p_value_correct_retrieval_count = kg_rag_no_nan[kg_rag_no_nan.contains_pvalue==True].shape[0]\n",
    "kg_rag_total_correct_retrieval = kg_rag_yes_count + kg_rag_p_value_correct_retrieval_count\n",
    "\n",
    "clear_output()\n",
    "\n",
    "neo4j_rag_total_correct_retrieval_percentage = 100*neo4j_rag_total_correct_retrieval/neo4j_rag.shape[0]\n",
    "kg_rag_total_correct_retrieval_percentage = 100*kg_rag_total_correct_retrieval/kg_rag.shape[0]\n",
    "\n",
    "print(f'Correct retrieval percentage for Cypher-RAG {neo4j_rag_total_correct_retrieval_percentage}%')\n",
    "print(f'Correct retrieval percentage for KG-RAG {kg_rag_total_correct_retrieval_percentage}%')\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "360a6019",
   "metadata": {},
   "source": [
    "### KG-RAG"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "0a433581",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Correct retrieval percentage for Cypher-RAG after name perturbation 0.0%\n",
      "Correct retrieval percentage for KG-RAG after name perturbation 97.0%\n"
     ]
    }
   ],
   "source": [
    "\n",
    "neo4j_rag_no_nan = neo4j_rag.dropna(subset=['neo4j_rag_answer_perturbed'])\n",
    "neo4j_rag_no_nan.loc[:, 'contains_pvalue'] = neo4j_rag_no_nan.apply(lambda row: str(row['gwas_pvalue']) in str(row['neo4j_rag_answer_perturbed']), axis=1)\n",
    "neo4j_rag_yes_count_df = neo4j_rag_no_nan[neo4j_rag_no_nan.neo4j_rag_answer_perturbed.str.contains('Yes')]\n",
    "neo4j_rag_yes_count = neo4j_rag_yes_count_df.shape[0]\n",
    "indices_to_remove = neo4j_rag_yes_count_df.index.tolist()\n",
    "neo4j_rag_no_nan = neo4j_rag_no_nan.drop(indices_to_remove)\n",
    "neo4j_rag_p_value_correct_retrieval_count = neo4j_rag_no_nan[neo4j_rag_no_nan.contains_pvalue==True].shape[0]\n",
    "neo4j_rag_total_correct_retrieval_perturbed = neo4j_rag_yes_count + neo4j_rag_p_value_correct_retrieval_count\n",
    "\n",
    "kg_rag_no_nan = kg_rag.dropna(subset=['kg_rag_answer_perturbed'])\n",
    "kg_rag_yes_count_df = kg_rag_no_nan[kg_rag_no_nan.kg_rag_answer_perturbed.str.contains('Yes')]\n",
    "kg_rag_yes_count = kg_rag_yes_count_df.shape[0]\n",
    "indices_to_remove = kg_rag_yes_count_df.index.tolist()\n",
    "kg_rag_no_nan = kg_rag_no_nan.drop(indices_to_remove)\n",
    "kg_rag_no_nan.loc[:, 'contains_pvalue'] = kg_rag_no_nan.apply(lambda row: str(row['gwas_pvalue']) in str(row['kg_rag_answer_perturbed']), axis=1)\n",
    "kg_rag_p_value_correct_retrieval_count = kg_rag_no_nan[kg_rag_no_nan.contains_pvalue==True].shape[0]\n",
    "kg_rag_total_correct_retrieval_perturbed = kg_rag_yes_count + kg_rag_p_value_correct_retrieval_count\n",
    "\n",
    "clear_output()\n",
    "\n",
    "neo4j_rag_total_correct_retrieval_perturbed_percentage = 100*neo4j_rag_total_correct_retrieval_perturbed/neo4j_rag.shape[0]\n",
    "kg_rag_total_correct_retrieval_perturbed_percentage = 100*kg_rag_total_correct_retrieval_perturbed/kg_rag.shape[0]\n",
    "\n",
    "print(f'Correct retrieval percentage for Cypher-RAG after name perturbation {neo4j_rag_total_correct_retrieval_perturbed_percentage}%')\n",
    "print(f'Correct retrieval percentage for KG-RAG after name perturbation {kg_rag_total_correct_retrieval_perturbed_percentage}%')\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d72ebbfa",
   "metadata": {},
   "source": [
    "### Bar plot"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "e6d8690d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYYAAAEhCAYAAAB7mQezAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/H5lhTAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAyJklEQVR4nO3deVRU9f8/8OewjcjIICibIaDggvuSgpZWYLh8co2MDx5xSctQUbSUUnEnLddcMhfET+6aS5qWIbiEu+LyURENA03gU8mMuLDN+/uHP+/PG6iMDjMDPh/nzDnM+955z3MunHlx7/ve+1YIIQSIiIj+HwtTByAiIvPCwkBERDIsDEREJMPCQEREMiwMREQkw8JAREQyLAxERCTDwkBERDIsDACEENBqteC1fkRELAwAgDt37kCtVuPOnTumjkJEZHJWpnzzgwcP4ssvv8SpU6dw69YtbNu2DT179pSWCyEQExOD5cuXIzc3F+3bt8fSpUvh6+srrfP3339jxIgR+OGHH2BhYYE+ffpgwYIFUKlUJvhEROanuLgYhYWFpo5BJmRtbQ1LS8syr2/SwnD37l00a9YMgwYNQu/evUssnz17NhYuXIj4+Hh4e3tj4sSJCA4OxsWLF1GlShUAQFhYGG7duoV9+/ahsLAQAwcOxNChQ7Fu3TpjfxwisyKEQFZWFnJzc00dhcyAg4MDXF1doVAonrmuwlxuoqdQKGR7DEIIuLu7Y8yYMRg7diwAQKPRwMXFBatXr8b777+PS5cuwc/PDydOnEDr1q0BAHv37kXXrl1x48YNuLu7l+m9tVot1Go1NBoN7O3ty+XzERnbrVu3kJubC2dnZ1StWrVMXwhU+QghcO/ePeTk5MDBwQFubm7PfI1J9xieJj09HVlZWQgKCpLa1Go12rZtiyNHjuD999/HkSNH4ODgIBUFAAgKCoKFhQWOHTuGXr16ldp3fn4+8vPzpedarbb8PgiRCRQXF0tFwcn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ev4888/odPp0LZtW1StWhWfffYZrl27hnXr1mH16tVlzpqRkYGoqCikpqZi/fr1+Prrr6Ws9erVQ1hYGPr374/vv/8e6enpOH78OGJjY7F7924AwMiRI7F371589dVXSEtLw6JFi8rlMNKTlCXjk3h5eUm/6z///BOFhYXw8fGBh4cHJk+ejLS0NOzevRtz5swpc56CggIMHjwYFy9exI8//oiYmBgMHz4cFhYWqFatGsaOHYvRo0cjPj4e165dw+nTp/H1118jPj4eAPDRRx8hLS0Nn3zyCVJTU/X+fRIZnKkHOUzt+PHjolOnTqJmzZpCrVaLtm3bim3btknLSxusjIyMFB07dpSee3p6iilTpoiQkBBRtWpV4erqKhYsWCB7jVarFSNGjBDu7u7C2tpaeHh4iLCwMJGRkSGEeDhY3KxZsxL5UlNThb+/v7C1tZUNhm7btk34+PgIW1tb8a9//Ut8++23JQafS+uvY8eO4uOPPxYfffSRsLe3F9WrVxefffaZbDC6oKBATJo0SXh5eQlra2vh5uYmevXqJc6dOyets3LlSvHKK68IW1tb8c4774ivvvqqXAef/+lZGUsboBdCiJycHNGpUyehUqkEAJGYmCiEEOLw4cOiSZMmokqVKuL1118XmzdvLjH4XFp/jzJOmjRJODk5CZVKJYYMGSI70UCn04n58+eL+vXrC2tra1GzZk0RHBwsDhw4IK3zww8/CB8fH6FUKsXrr78uVq1axcFnMhnedtsAvLy8MGrUqJf2CmUiqlxe6kNJRERUEgsDERHJ8FASERHJcI+BiIhkWBiIiEiGhYGIiGRYGIiISIaFgYiIZFgYiIhIhoWBiIhkWBiIiEjm/wCdJXLMmTxGVwAAAABJRU5ErkJggg==",
      "text/plain": [
       "<Figure size 400x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "\n",
    "categories = ['Unperturbed', 'Perturbed']\n",
    "neo4j_rag_percentage = [neo4j_rag_total_correct_retrieval_percentage, neo4j_rag_total_correct_retrieval_perturbed_percentage]\n",
    "kg_rag_percentage = [kg_rag_total_correct_retrieval_percentage, kg_rag_total_correct_retrieval_perturbed_percentage]\n",
    "\n",
    "neo4j_color = 'red'\n",
    "kg_rag_color = 'green'\n",
    "\n",
    "fig, ax = plt.subplots(figsize=(4, 3))\n",
    "\n",
    "bar_width = 0.35\n",
    "index = range(len(categories))\n",
    "\n",
    "ax.bar(index, neo4j_rag_percentage, bar_width, color=neo4j_color, label='Cypher-RAG')\n",
    "ax.bar([i + bar_width for i in index], kg_rag_percentage, bar_width, color=kg_rag_color, label='KG-RAG')\n",
    "\n",
    "ax.set_ylabel('Retrieval accuracy')\n",
    "ax.set_xticks([i + bar_width / 2 for i in index])\n",
    "ax.set_xticklabels(categories)\n",
    "\n",
    "\n",
    "ax.legend(loc='center left', bbox_to_anchor=(1, 0.9))\n",
    "\n",
    "sns.despine()\n",
    "\n",
    "plt.tight_layout()\n",
    "plt.show()\n",
    "\n",
    "fig_path = '../data/results/figures'\n",
    "os.makedirs(fig_path, exist_ok=True)\n",
    "fig.savefig(os.path.join(fig_path, 'retrieval_accuracy_comparison.svg'), format='svg', bbox_inches='tight')      \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "ecf8bd99",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[75.0, 0.0]"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "neo4j_rag_percentage"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "5f316867",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[97.0, 97.0]"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "kg_rag_percentage"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "269c8dc7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "8006"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "round(neo4j_avg)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "56494f88",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3693"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "round(kg_avg)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
